//
//  SYRequestAPI+SYZiYuan.m
//  SanYiTeaching
//
//  Created by 郑浩然 on 2019/5/13.
//  Copyright © 2019年 SanYi. All rights reserved.
//
//我收藏得文件
NSString *const kSYMinCollectionBaseUrl = @"resource/CollectionResourceService.svc/";
//我的文件夹
NSString *const kSYMinResourceBaseUrl = @"/resource/MyResourceService.svc/";


#import "SYRequestAPI+SYZiYuan.h"

@implementation SYRequestAPI (SYZiYuan)
//我收藏得文件
+ (void)zy_resourceCollectionCollectionListPageIndex:(NSInteger)index
                                            pageSize:(NSInteger)size
                                             sortPid:(NSString *)sortPid
                                         isTinyClass:(NSString *)tinyClass
                                            onlySort:(NSString *)onlySort
                                             success:(void(^)(NSMutableArray *listArr))success
                                                fail:(FailBlock)fail
{
    NSString *url = SYStringWithPickFormat(kSYMinCollectionBaseUrl, @"CollectionList");
    
    NSDictionary *dict = @{
                           @"pageIndex":SJStringWithFormat(index),
                           @"pageSize":SJStringWithFormat(size),
                           @"sortPId":sortPid,
                           @"isTinyClass":tinyClass,
                           @"onlySort":onlySort
                           };
    
    [SYRequestAPI postDataFromURLScheme:url parameterDictionary:dict success:^(id responseObject) {
        NSDictionary *diction = responseObject[@"data"];
        NSMutableArray *arr = [[SYCollectionModel alloc] requestDiction:diction];
        if (success) {
            success(arr);
        }
        
    } fail:^(NSError *error) {
        if (fail) {
            fail(error);
        }
        
    }];
}
//添加收藏
+ (void)zy_resourceCollectionAddCollectionId:(NSString *)zyId
                                      infoId:(NSString *)infoId
                                    infoType:(NSString *)infoType
                                     success:(void(^)(BOOL isSuccess))success
                                        fail:(FailBlock)fail
{
    NSString *url = SYStringWithPickFormat(kSYMinCollectionBaseUrl, @"AddCollection");
    
    NSDictionary *dict = @{
                           @"id":zyId,
                           @"infoId":infoId,
                           @"infoType":infoType
                           };
    
    [SYRequestAPI postDataFromURLScheme:url parameterDictionary:dict success:^(id responseObject) {
        
    } fail:^(NSError *error) {
        
    }];
}

//删除收藏
+ (void)zy_resourceCollectionRemoveCollectionid:(NSString *)zyId
                                       onlySort:(NSString *)onlySort
                                        success:(void(^)(BOOL isSuccess))success
                                           fail:(FailBlock)fail
{
    NSString *url = SYStringWithPickFormat(kSYMinCollectionBaseUrl, @"RemoveCollection");
    
    NSDictionary *dict = @{
                           @"id":zyId,
                           @"onlySort":onlySort
                           };
    
    [SYRequestAPI postDataFromURLScheme:url parameterDictionary:dict success:^(id responseObject) {
        if (success) {
            success(YES);
        }
    } fail:^(NSError *error) {
        if (error) {
            fail(error);
        }
    }];
}
//移动文件
+ (void)zy_requestMyResourceServiceMoveFileId:(NSString *)wjId
                                      typePid:(NSString *)typePid
                                     onlySort:(NSString *)onlySort
                                      success:(void(^)(BOOL isSuccess))success
                                         fail:(FailBlock)fail
{
    NSString *url = SYStringWithPickFormat(kSYMinResourceBaseUrl, @"MoveFile");
    
    NSDictionary *dict = @{
                           @"id":wjId,
                           @"typePid":typePid,
                           @"onlySort":onlySort
                           };
    
    [SYRequestAPI postDataFromURLScheme:url parameterDictionary:dict success:^(id responseObject) {
        if (success) {
            success(YES);
        }
    } fail:^(NSError *error) {
        if (error) {
            fail(error);
        }
    }];
}
//重命名文件
+ (void)zy_requestMyRenameFileFileName:(NSString *)fileName
                                  wjId:(NSString *)wjId
                              onlySort:(NSString *)onlySort
                               success:(void(^)(BOOL isSuccess))success
                                  fail:(FailBlock)fail
{
    NSString *url = SYStringWithPickFormat(kSYMinResourceBaseUrl, @"RenameFile");
    
    NSDictionary *dict = @{
                           @"id":wjId,
                           @"fileName":fileName,
                           @"onlySort":onlySort
                           };
    
    [SYRequestAPI postDataFromURLScheme:url parameterDictionary:dict success:^(id responseObject) {
        if (success) {
            success(YES);
        }
    } fail:^(NSError *error) {
        if (error) {
            fail(error);
        }
    }];
}
//我的文件
+ (void)zy_requestMyResourceListPageIndex:(NSInteger)pageIndex
                                 pageSize:(NSInteger)pageSize
                                   sortId:(NSString *)sortId
                              isTinyClass:(NSString *)isTinyClass
                                 onlySort:(NSString *)onlySort
                                  keyWord:(NSString *)keyWord
                                  success:(void(^)(NSMutableArray *listArr))success
                                     fail:(FailBlock)fail
{
    NSString *url = SYStringWithPickFormat(kSYMinResourceBaseUrl, @"MyResourceList");
    
    NSDictionary *dict = @{
                           @"pageIndex":SJStringWithFormat(pageIndex),
                           @"pageSize":SJStringWithFormat(pageSize),
                           @"sortId":sortId,
                           @"isTinyClass":isTinyClass,
                           @"onlySort":onlySort,
                           @"keyWord":keyWord
                           };
    
    [SYRequestAPI postDataFromURLScheme:url parameterDictionary:dict success:^(id responseObject) {
        NSDictionary *diction = responseObject[@"data"];
        NSMutableArray *arr = [[SYCollectionModel alloc] requestDiction:diction];
        if (success) {
            success(arr);
        }
        
    } fail:^(NSError *error) {
        if (fail) {
            fail(error);
        }
        
    }];
}
//辅导视频id
+ (void)zy_requestTutorClassServiceTutorId:(NSString *)tutorId
                                   success:(void(^)(NSMutableArray *listArr))success
                                      fail:(FailBlock)fail
{
    NSString *url = @"tutor/TutorClassService.svc/GetTutorVideoInfo";
    
    NSDictionary *dict = @{@"tutorId":tutorId};
    [SYRequestAPI postDataFromURLScheme:url parameterDictionary:dict success:^(id responseObject) {
        NSArray *data = responseObject[@"data"];
        NSMutableArray *dataArr = [NSMutableArray new];
        for (NSDictionary *dict in data) {
            SYPlayerTutorModel *tutorModel = [SYPlayerTutorModel yy_modelWithDictionary:dict];
            tutorModel.dataTutorRecordArr = [NSMutableArray new];
            NSArray *recordArr = [dict nilObjectForKey:@"dataTutorRecord"];
            if (recordArr != nil && recordArr.count >0) {
                for (NSDictionary *recordDict in recordArr) {
                    SYPlayerTutorRecordModel *recordeModel = [SYPlayerTutorRecordModel yy_modelWithDictionary:recordDict];
                    recordeModel.dateTutorVideoArr = [NSMutableArray new];
                    //视频详情
                    NSArray *videoArr = [recordDict nilObjectForKey:@"dateTutorVideo"];
                    if (videoArr != nil && videoArr.count > 0) {
                        for (NSDictionary *videoDict in videoArr) {
                            SYPlayerTutorVideoModel *videoModel = [SYPlayerTutorVideoModel yy_modelWithDictionary:videoDict];
                            [recordeModel.dateTutorVideoArr addObject:videoModel];
                        }
                    }
                    [tutorModel.dataTutorRecordArr addObject:recordeModel];
                }
            }
            
            [dataArr addObject:tutorModel];
        }
        if (success) {
            success(dataArr);
        }
        
    } fail:^(NSError *error) {
        
    }];
    
}

+ (void)zy_requestMyResourceAddDirectoryName:(NSString *)directioryName
                                     typePid:(NSString *)typePid
                                    category:(NSString *)category
                                     success:(void(^)(BOOL isSuccess))success
                                        fail:(FailBlock)fail
{
    NSString *url = SYStringWithPickFormat(kSYMinResourceBaseUrl, @"AddDirectory");
    
    NSDictionary *dict = @{
                           @"directoryName":directioryName,
                           @"typePid":typePid,
                           @"category":category
                           };
    
    [SYRequestAPI postDataFromURLScheme:url parameterDictionary:dict success:^(id responseObject) {
        if (success) {
            success(YES);
        }
        
    } fail:^(NSError *error) {
        if (fail) {
            fail(error);
        }
        
    }];
}
//删除文件夹
+ (void)zy_requestMyDeleteFileId:(NSString *)dlid
                        onlySort:(NSString *)onlySort
                         success:(void(^)(BOOL isSuccess))success
                            fail:(FailBlock)fail
{
    NSString *url = SYStringWithPickFormat(kSYMinResourceBaseUrl, @"DeleteFile");
    
    NSDictionary *dict = @{
                           @"id":dlid,
                           @"onlySort":onlySort
                           };
    
    [SYRequestAPI postDataFromURLScheme:url parameterDictionary:dict success:^(id responseObject) {
        if (success) {
            success(YES);
        }
        
    } fail:^(NSError *error) {
        if (fail) {
            fail(error);
        }
        
    }];
}

+ (void)zy_requestSaveResource:(NSString *)sortid
                          path:(NSString *)path
                   isTinyClass:(NSString *)isTiny
                       success:(void(^)(BOOL isSuccess))success
                          fail:(FailBlock)fail
{
    NSString *url = @"resource/MyResourceService.svc/SaveResource";
    NSDictionary *dict = @{@"sortId":sortid,
                           @"path":path,
                           @"isTinyClass":isTiny
                           };
    
    
    [SYRequestAPI postDataFromURLScheme:url parameterDictionary:dict success:^(id responseObject) {
        if (success) {
            success(YES);
        }
    } fail:^(NSError *error) {
        if (fail) {
            fail(error);
        }
    }];
    
    
}

+ (void)zy_requestEmployeeResourceFiledId:(NSString *)filedId
                                  success:(void(^)(BOOL isSuccess))success
                                     fail:(FailBlock)fail
{
    NSString *url = @"resource/MyResourceService.svc/EmployeeResourceReportToGroup";
    NSDictionary *dict = @{@"fileId":filedId};
    [SYRequestAPI postDataFromURLScheme:url parameterDictionary:dict success:^(id responseObject) {
        if (success) {
            success(YES);
        }
    } fail:^(NSError *error) {
        if (fail) {
            fail(error);
        }
    }];
    
    
}
+ (void)zy_requestGetGroupInfoName:(NSString *)groupName
                         pageIndex:(NSInteger)pageIndex
                          pageSize:(NSInteger)pageSize
                           success:(void(^)(NSArray *arr))success
                              fail:(FailBlock)fail
{
    NSString *url = @"resource/MyResourceService.svc/GetGroupInfo";
    NSDictionary *dict = @{@"resourceGroupName":groupName,
                           @"pageIndex":SJStringWithFormat(pageIndex),
                           @"pageSize":SJStringWithFormat(pageSize)
                           };
    [SYRequestAPI postDataFromURLScheme:url parameterDictionary:dict success:^(id responseObject) {
        NSArray *dataArr = [responseObject nilObjectForKey:@"data"];
        if (success) {
            success(dataArr);
        }
    } fail:^(NSError *error) {
        if (fail) {
            fail(error);
        }
    }];
    
}
+ (void)zy_requestGetGroupPckgeListGroupid:(NSString *)groupId
                               packageName:(NSString *)packageName
                                   success:(void(^)(NSArray *arr))success
                                      fail:(FailBlock)fail
{
    NSString *url = @"resource/MyResourceService.svc/GetGroupPackageList";
    NSDictionary *dict = @{@"resourceGroupId":groupId,
                                                      };
    [SYRequestAPI postDataFromURLScheme:url parameterDictionary:dict success:^(id responseObject) {
        NSArray *dataArr = [responseObject nilObjectForKey:@"data"];
        if (success) {
            success(dataArr);
        }
    } fail:^(NSError *error) {
        if (fail) {
            fail(error);
        }
    }];
}
//获取教材包的教材
+ (void)zy_requestGetResourceEmployeeListPackageId:(NSString *)packageId
                                           success:(void(^)(NSArray *arr))success
                                              fail:(FailBlock)fail
{
    NSString *url = @"resource/MyResourceService.svc/GetResourceEmployeeListByPackageId";
    NSDictionary *dict = @{@"resourcePackageId":packageId,
                           };
    [SYRequestAPI postDataFromURLScheme:url parameterDictionary:dict success:^(id responseObject) {
        NSArray *dataArr = [responseObject nilObjectForKey:@"data"];
        if (success) {
            success(dataArr);
        }
    } fail:^(NSError *error) {
        if (fail) {
            fail(error);
        }
    }];
}
//获取分享的班级
+ (void)zy_requestGetGroupPackageClassListGroupId:(NSString *)groupId
                                        packageId:(NSString *)packageId
                                          success:(void(^)(NSArray *arr))success
                                             fail:(FailBlock)fail
{
    NSString *url = @"resource/MyResourceService.svc/GetGroupPackageClassList";
    NSDictionary *dict = @{@"resourceGroupId":groupId,
                           @"resourcePackageId":packageId
                           };
    [SYRequestAPI postDataFromURLScheme:url parameterDictionary:dict success:^(id responseObject) {
        NSArray *dataArr = [responseObject nilObjectForKey:@"data"];
        if (success) {
            success(dataArr);
        }
    } fail:^(NSError *error) {
        if (fail) {
            fail(error);
        }
    }];
}
//组成员信息
+ (void)zy_requestGetGroupMemberListGroupId:(NSString *)groupId
                                    success:(void(^)(NSArray *arr))success
                                       fail:(FailBlock)fail
{
    NSString *url = @"resource/MyResourceService.svc/GetGroupMemberList";
    NSDictionary *dict = @{@"resourceGroupId":groupId
                           
                           };
    [SYRequestAPI postDataFromURLScheme:url parameterDictionary:dict success:^(id responseObject) {
        NSArray *dataArr = [responseObject nilObjectForKey:@"data"];
        if (success) {
            success(dataArr);
        }
    } fail:^(NSError *error) {
        if (fail) {
            fail(error);
        }
    }];
}
//教材包到班级
+ (void)zy_requestAddGroupPackageClassGroupid:(NSString *)groupId
                                     campusid:(NSString *)campusId
                              resourceGroupId:(NSString *)resourceGroupId
                            resourcePackageId:(NSString *)resourcePackageId
                                      classId:(NSString *)classId
                                    grandDate:(NSString *)grandDate
                                  recycleDate:(NSString *)recycleDate
                                      success:(void(^)(BOOL isSuccess))success
                                         fail:(FailBlock)fail
{
    NSString *url = @"resource/MyResourceService.svc/AddGroupPackageClass";
    NSDictionary *dict = @{@"groupId":groupId,
                           @"campusId":campusId,
                           @"resourceGroupId":resourceGroupId,
                           @"resourcePackageId":resourcePackageId,
                           @"classId":classId,
                           @"grandDate":grandDate,
                           @"recycleDate":recycleDate,
                           };
    [SYRequestAPI postDataFromURLScheme:url parameterDictionary:dict success:^(id responseObject) {
        if (success) {
            success(YES);
        }
    } fail:^(NSError *error) {
        if (fail) {
            fail(error);
        }
    }];
}
@end




























